package com.atguigu.controller;

import com.atguigu.pojo.User;
import com.atguigu.res.ResultData;
import com.atguigu.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class UserController {
    @Autowired
    private UserService userService;
    @PostMapping(value = "/user/add")
    public ResultData<Boolean> addUser(@RequestBody User user){
        return ResultData.success(userService.save(user));
    }
    @GetMapping(value = "/user/{id}")
    public ResultData<User> getUserById(@PathVariable Integer id){
        return ResultData.success(userService.getById(id));
    }

}
